/* ---------------------------------------------Marlin Toolkit----------------------------------------*
Authors : Daniel Randle, Alex Bourne
Date Created : Mar 28 2013

File:
hextiledialog.cpp

Description:
This file contains the definition for the HexTileDialog class functions along with any
helper functions associated with the class
*-----------------------------------------------------------------------------------------------------*/


#include <hextiledialog.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <qfiledialog.h>

namespace ToolkitGui
{

HexTileDialog::HexTileDialog(QWidget * parent, Qt::WindowFlags f): QDialog(parent,f),
	isDirty(false)
{
	_initObjects();
	_setupUi();
	_setupConnections();
}


void HexTileDialog::_initObjects()
{}

void HexTileDialog::_setupUi()
{
	setupUi(this);
    QRect scr = QApplication::desktop()->screenGeometry();
    move( scr.center()/2 - rect().center() );
}

void HexTileDialog::_setupConnections()
{
	connect(cancelB, SIGNAL(clicked()), this, SLOT(onCancel()));
	connect(okayB, SIGNAL(clicked()), this, SLOT(onOkay()));
	connect(applyB, SIGNAL(clicked()), this, SLOT(onApply()));
	connect(browseB, SIGNAL(clicked()), this, SLOT(onBrowse()));
}

void HexTileDialog::onOkay()
{
	onApply();
	done(Accepted);
}

void HexTileDialog::onApply()
{
	emit applied();
	isDirty = false;
}

void HexTileDialog::onCancel()
{
	done(Rejected);
}

void HexTileDialog::onBrowse()
{
	QString fName = QFileDialog::getOpenFileName(this, "Choose mesh file","Meshes","*.dae");
	if (fName == QString())
		return;
	modelLE->setText(fName);
}

}